apply_transfer
@mount("ft4.crosschain.apply_transfer")
operation apply_transfer(init_transfer_tx: gtx_transaction, init_tx_op_index: integer, previous_hop_tx: gtx_transaction, op_index: integer, hop_index: integer)This operation must be called on every chain listed in the hops array
provided to the init_transfer function which corresponds to this transfer.
When this is done, one of two things will happen:
- If this is an intermediary hop, this chain will update its internal record of which chain that owns how much of what asset
- If this is the final hop, the transferred amount will be credited to the recipient account
In the case where this is the last hop and the recipient account does not exist, one of two things can happen:
- If the create on transfer account creation strategy is enabled, the assets will be received and the recipient will be able create the account and claim them.
- If the feature is not enabled, the transfer will be rejected, in which case, the sender can
get their assets back by calling the
cancel_transferin the reverse hops order.
Anyone can call this operation on behalf of any transfer, but it needs to include an iccf_proof
operation which prove that the transaction was applied in the previous hop.
The functionality provided by apply_transfer can be modified by extending
before_apply_transfer and after_apply_transfer
Throws "TRANSFER EXPIRED"` if deadline is a past timestamp
Throws "MISSING ACCOUNT" if all these conditions apply:
- this chain is the last chain in the crosschain transaction
- the account corresponding to
recipient_iddoes not exist - creating account on crosschain transfer is not enabled on this chain
Throws if additional conditions provided through extensions of before_apply_transfer and
after_apply_transfer are not satisfied
Throws if the current transfer is misconfigured. Common cases are:
- the next hop or the previous one are:
- equal to one another
- this blockchain's RID
- the ID of an account on this chain which is not a blockchain account
- amount is:
- not in the accepted range (0, 2^256) (exclusive)
- higher than the blockchain account balance they're coming from
- the asset is not registered on this chain
- input is malformed:
- arguments found in
init_transfer_txandprevious_hop_txdo not match hop_indexis out of boundsprevious_hop_txhas not been sent to the chain that comes before this one on the transfer hops
- arguments found in
- the transfer has already been applied, canceled or unapplied on this chain.
- the chain at
hop_indexon the init transaction is not this chain - the
op_indexonprevious_hop_txdoes not point to:init_transferwhenhop_indexis 0apply_transferotherwise
- the
init_tx_op_indexdoes not point toinit_transferon itsinit_transfer_tx - the operation preceding
init_transferis not an auth operation
Throws if all these conditions apply:
- this chain is the last chain in the crosschain transaction
- the account corresponding to
recipient_iddoes not exist - creating account on crosschain transfer is enabled on this chain
- the function implementing the account creation strategy being used (extension of
create_on_crosschain_transfer) has conditions which are not satisfied
Throws if the transaction is missing the iccf_proof operation, which demonstrates that
the block containing the previous_hop_tx has been anchored from the previous chain.
Requires no flags - no authorization is performed to apply a transfer.
Parameters
- init_transfer_tx — the
gtx_transactionthat represents the tx containing theinit_transferoperation on the initial chain - init_tx_op_index — the index of the
init_transferoperation ininit_transfer_tx - previous_hop_tx — the tx containing the
init_transferorapply_transferoperation from the previous step. In the first hop,init_transfer_txand this argument will be the same - op_index — the index of the
apply_transferoperation inprevious_hop_tx - hop_index — which index in the hops array provided in the original transaction this chain represents.
See Also
- [core.auth.is_auth_op] — for information on auth operations
- [core.crosschain.before_apply_transfer] — to add custom logic before this operation
- [core.crosschain.after_apply_transfer] — to add custom logic after this operation
- [core.crosschain.applied_transfers] — to know more about the crosschain transfer workflow
- [core.crosschain.is_create_on_crosschain_transfer_enabled] — to know more about account creation on crosschain transfer